﻿//
// Copyright (c) 2019-2023 BPer
//

#ifndef BPERCAPTURE_SRC_BPerVideoCaptureMac_H_
#define BPERCAPTURE_SRC_BPerVideoCaptureMac_H_

#include <bpercapture/BPerVideoCaptureHandle.h>
#include <bpercapture/BPerMultiVideoCapture.h>

#if BPer_OS_APPLE
#include <bpercapture/mac/BPerVideoDeviceMac.h>

class BPerVideoCaptureMac: public BPerMultiVideoCapture {
public:
	BPerVideoCaptureMac(BPerVideoInfo *pcontext);
	~BPerVideoCaptureMac();
	BPerVideoCaptureHandle *m_vhandle;
	int32_t init();
	void setVideoCaptureStart();
	void setVideoCaptureStop();
	void setOutVideoBuffer(BPerVideoBuffer *pbuf);
	void setPreVideoBuffer(BPerVideoBuffer *pbuf);
	int32_t getVideoCaptureState();
	void initstamp();
	void stopLoop();

	int32_t getLivingVideoCaptureState();
	int32_t getFilmVideoCaptureState();

	void setLivingOutVideoBuffer(BPerVideoBuffer *pbuf);
	void setLivingVideoCaptureStart();
	void setLivingVideoCaptureStop();

	void setFilmOutVideoBuffer(BPerVideoBuffer *pbuf);
	void setFilmVideoCaptureStart();
	void setFilmVideoCaptureStop();
    void on_video(uint8_t* data,uint32_t nb,uint64_t ts);
protected:
	void startLoop();
	long m_difftime(struct timeval *p_start, struct timeval *p_end);
private:
    BPerVideoDeviceMac* m_device;
	int32_t m_width, m_height;
    BPerBool m_isloop;
    BPerBool m_waitState;
    bPer_thread_mutex_t m_lock;
    bPer_thread_cond_t m_cond_mess;


};
#endif
#endif /* BPERCAPTURE_SRC_BPERVIDEOCAPTUREIMPL_H_ */
